<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE CApiFFI #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Module      :  System.Environment.Blank</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Copyright   :  (c) Habib Alamin 2017</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- A setEnv implementation that allows blank environment variables. Mimics</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- the `System.Posix.Env` module from the @unix@ package, but with support</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- for Windows too.</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- The matrix of platforms that:</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">--   * support @putenv(&quot;FOO&quot;)@ to unset environment variables,</span><span>
</span><span id="line-22"></span><span class="hs-comment">--   * support @putenv(&quot;FOO=&quot;)@ to unset environment variables or set them</span><span>
</span><span id="line-23"></span><span class="hs-comment">--     to blank values,</span><span>
</span><span id="line-24"></span><span class="hs-comment">--   * support @unsetenv@ to unset environment variables,</span><span>
</span><span id="line-25"></span><span class="hs-comment">--   * support @setenv@ to set environment variables,</span><span>
</span><span id="line-26"></span><span class="hs-comment">--   * etc.</span><span>
</span><span id="line-27"></span><span class="hs-comment">--</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- is very complicated. Some platforms don't support unsetting of environment</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- variables at all.</span><span>
</span><span id="line-30"></span><span class="hs-comment">--</span><span>
</span><span id="line-31"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Environment.Blank</span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-35"></span><span>      </span><span class="hs-keyword">module</span><span> </span><span class="annot"><a href="System.Environment.html"><span class="hs-identifier">System.Environment</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>      </span><span class="annot"><a href="System.Environment.Blank.html#getEnv"><span class="hs-identifier">getEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>      </span><span class="annot"><a href="System.Environment.Blank.html#getEnvDefault"><span class="hs-identifier">getEnvDefault</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>      </span><span class="annot"><a href="System.Environment.Blank.html#setEnv"><span class="hs-identifier">setEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>      </span><span class="annot"><a href="System.Environment.Blank.html#unsetEnv"><span class="hs-identifier">unsetEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.html"><span class="hs-identifier">Foreign.C</span></a></span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-pragma">{-# LINE 44 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Ptr</span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Windows.html"><span class="hs-identifier">GHC.Windows</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Monad.html"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-47"></span><span>
</span><span id="line-48"></span><span class="hs-pragma">{-# LINE 50 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Exception.html"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.IO.Error.html"><span class="hs-identifier">System.IO.Error</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Exception.Base.html"><span class="hs-identifier">Control.Exception.Base</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Maybe.html"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Environment.html"><span class="hs-identifier">System.Environment</span></a></span><span>
</span><span id="line-56"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-57"></span><span>      </span><span class="annot"><a href="System.Environment.html#getArgs"><span class="hs-identifier">getArgs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-58"></span><span>      </span><span class="annot"><a href="System.Environment.html#getProgName"><span class="hs-identifier">getProgName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-59"></span><span>      </span><span class="annot"><a href="System.Environment.ExecutablePath.html#getExecutablePath"><span class="hs-identifier">getExecutablePath</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-60"></span><span>      </span><span class="annot"><a href="System.Environment.html#withArgs"><span class="hs-identifier">withArgs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>      </span><span class="annot"><a href="System.Environment.html#withProgName"><span class="hs-identifier">withProgName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-62"></span><span>      </span><span class="annot"><a href="System.Environment.html#getEnvironment"><span class="hs-identifier">getEnvironment</span></a></span><span>
</span><span id="line-63"></span><span>  </span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-pragma">{-# LINE 67 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-comment">-- TODO: include windows_cconv.h when it's merged, instead of duplicating</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- this C macro block.</span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-pragma">{-# LINE 71 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-pragma">{-# LINE 74 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span class="hs-cpp">
#  define WINDOWS_CCONV ccall
</span><span>
</span><span id="line-76"></span><span class="hs-pragma">{-# LINE 78 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-pragma">{-# LINE 79 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span id="local-6989586621679564513"><span class="annot"><a href="System.Environment.Blank.html#throwInvalidArgument"><span class="hs-identifier hs-type">throwInvalidArgument</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679564513"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-83"></span><span id="throwInvalidArgument"><span class="annot"><span class="annottext">throwInvalidArgument :: forall a. String -&gt; IO a
</span><a href="System.Environment.Blank.html#throwInvalidArgument"><span class="hs-identifier hs-var hs-var">throwInvalidArgument</span></a></span></span><span> </span><span id="local-6989586621679564443"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564443"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-84"></span><span>  </span><span class="annot"><span class="annottext">IOError -&gt; IO a
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOErrorType -&gt; String -&gt; Maybe Handle -&gt; Maybe String -&gt; IOError
</span><a href="System.IO.Error.html#mkIOError"><span class="hs-identifier hs-var">mkIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#InvalidArgument"><span class="hs-identifier hs-var">InvalidArgument</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564443"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-comment">-- | Similar to 'System.Environment.lookupEnv'.</span><span>
</span><span id="line-87"></span><span class="annot"><a href="System.Environment.Blank.html#getEnv"><span class="hs-identifier hs-type">getEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span>
</span><span id="line-89"></span><span id="getEnv"></span><span class="hs-pragma">{-# LINE 89 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-89"></span><span class="hs-identifier">getEnv</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-operator">&lt;$&gt;</span><span> </span><span class="hs-identifier">getEnvironment</span><span class="hs-special">)</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">lookup</span><span>
</span><span id="line-90"></span><span>
</span><span id="line-91"></span><span class="hs-pragma">{-# LINE 93 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-comment">-- | Get an environment value or a default value.</span><span>
</span><span id="line-95"></span><span class="annot"><a href="System.Environment.Blank.html#getEnvDefault"><span class="hs-identifier hs-type">getEnvDefault</span></a></span><span> </span><span class="hs-glyph">::</span><span>
</span><span id="line-96"></span><span>  </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>    </span><span class="hs-comment">{- ^ variable name                    -}</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-97"></span><span>  </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>    </span><span class="hs-comment">{- ^ fallback value                   -}</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-98"></span><span>  </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-comment">{- ^ variable value or fallback value -}</span><span>
</span><span id="line-99"></span><span id="getEnvDefault"><span class="annot"><span class="annottext">getEnvDefault :: String -&gt; String -&gt; IO String
</span><a href="System.Environment.Blank.html#getEnvDefault"><span class="hs-identifier hs-var hs-var">getEnvDefault</span></a></span></span><span> </span><span id="local-6989586621679564436"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564436"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621679564435"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564435"><span class="hs-identifier hs-var">fallback</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe String -&gt; String
forall a. a -&gt; Maybe a -&gt; a
</span><a href="Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564435"><span class="hs-identifier hs-var">fallback</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe String -&gt; String) -&gt; IO (Maybe String) -&gt; IO String
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (Maybe String)
</span><a href="System.Environment.Blank.html#getEnv"><span class="hs-identifier hs-var">getEnv</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564436"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span class="hs-comment">-- | Like 'System.Environment.setEnv', but allows blank environment values</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- and mimics the function signature of 'System.Posix.Env.setEnv' from the</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- @unix@ package.</span><span>
</span><span id="line-104"></span><span class="annot"><a href="System.Environment.Blank.html#setEnv"><span class="hs-identifier hs-type">setEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span>
</span><span id="line-105"></span><span>  </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-comment">{- ^ variable name  -}</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-106"></span><span>  </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-comment">{- ^ variable value -}</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-107"></span><span>  </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>   </span><span class="hs-comment">{- ^ overwrite      -}</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-108"></span><span>  </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span id="setEnv"><span class="annot"><span class="annottext">setEnv :: String -&gt; String -&gt; Bool -&gt; IO ()
</span><a href="System.Environment.Blank.html#setEnv"><span class="hs-identifier hs-var hs-var">setEnv</span></a></span></span><span> </span><span id="local-6989586621679564433"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564433"><span class="hs-identifier hs-var">key_</span></a></span></span><span> </span><span id="local-6989586621679564432"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564432"><span class="hs-identifier hs-var">value_</span></a></span></span><span> </span><span id="local-6989586621679564431"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679564431"><span class="hs-identifier hs-var">overwrite</span></a></span></span><span>
</span><span id="line-110"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564429"><span class="hs-identifier hs-var">key</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO ()
forall a. String -&gt; IO a
</span><a href="System.Environment.Blank.html#throwInvalidArgument"><span class="hs-identifier hs-var">throwInvalidArgument</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setEnv&quot;</span></span><span>
</span><span id="line-111"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'='</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; String -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564429"><span class="hs-identifier hs-var">key</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO ()
forall a. String -&gt; IO a
</span><a href="System.Environment.Blank.html#throwInvalidArgument"><span class="hs-identifier hs-var">throwInvalidArgument</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setEnv&quot;</span></span><span>
</span><span id="line-112"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span>
</span><span id="line-113"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679564431"><span class="hs-identifier hs-var">overwrite</span></a></span><span>
</span><span id="line-114"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; IO ()
</span><a href="System.Environment.Blank.html#setEnv_"><span class="hs-identifier hs-var">setEnv_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564429"><span class="hs-identifier hs-var">key</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564426"><span class="hs-identifier hs-var">value</span></a></span><span>
</span><span id="line-115"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-116"></span><span>      </span><span id="local-6989586621679564425"><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621679564425"><span class="hs-identifier hs-var">env_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (Maybe String)
</span><a href="System.Environment.Blank.html#getEnv"><span class="hs-identifier hs-var">getEnv</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564429"><span class="hs-identifier hs-var">key</span></a></span><span>
</span><span id="line-117"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621679564425"><span class="hs-identifier hs-var">env_var</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-118"></span><span>          </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-119"></span><span>          </span><span class="annot"><span class="annottext">Maybe String
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; IO ()
</span><a href="System.Environment.Blank.html#setEnv_"><span class="hs-identifier hs-var">setEnv_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564429"><span class="hs-identifier hs-var">key</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564426"><span class="hs-identifier hs-var">value</span></a></span><span>
</span><span id="line-120"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-121"></span><span>    </span><span id="local-6989586621679564429"><span class="annot"><span class="annottext">key :: String
</span><a href="#local-6989586621679564429"><span class="hs-identifier hs-var hs-var">key</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; String
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.List.html#takeWhile"><span class="hs-identifier hs-var">takeWhile</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\NUL'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564433"><span class="hs-identifier hs-var">key_</span></a></span><span>
</span><span id="line-122"></span><span>    </span><span id="local-6989586621679564426"><span class="annot"><span class="annottext">value :: String
</span><a href="#local-6989586621679564426"><span class="hs-identifier hs-var hs-var">value</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; String
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.List.html#takeWhile"><span class="hs-identifier hs-var">takeWhile</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\NUL'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679564432"><span class="hs-identifier hs-var">value_</span></a></span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span class="annot"><a href="System.Environment.Blank.html#setEnv_"><span class="hs-identifier hs-type">setEnv_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span id="setEnv_"></span><span class="hs-pragma">{-# LINE 126 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span id="local-6989586621679564420"></span><span>
</span><span id="line-126"></span><span class="hs-identifier">setEnv_</span><span> </span><span class="hs-identifier">key</span><span> </span><span class="hs-identifier">value</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withCWString</span><span> </span><span class="hs-identifier">key</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">k</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">withCWString</span><span> </span><span class="hs-identifier">value</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">v</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-identifier">success</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_SetEnvironmentVariable</span><span> </span><span class="hs-identifier">k</span><span> </span><span class="hs-identifier">v</span><span>
</span><span id="line-128"></span><span>  </span><span class="hs-identifier">unless</span><span> </span><span class="hs-identifier">success</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">throwGetLastError</span><span> </span><span class="hs-string">&quot;setEnv&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetEnvironmentVariableW&quot;</span><span>
</span><span id="line-131"></span><span>  </span><span id="c_SetEnvironmentVariable"><span class="annot"><a href="System.Environment.Blank.html#c_SetEnvironmentVariable"><span class="hs-identifier hs-var">c_SetEnvironmentVariable</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPTSTR"><span class="hs-identifier hs-type">LPTSTR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPTSTR"><span class="hs-identifier hs-type">LPTSTR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-132"></span><span>
</span><span id="line-133"></span><span class="hs-pragma">{-# LINE 142 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- | Like 'System.Environment.unsetEnv', but allows for the removal of</span><span>
</span><span id="line-144"></span><span class="hs-comment">-- blank environment variables. May throw an exception if the underlying</span><span>
</span><span id="line-145"></span><span class="hs-comment">-- platform doesn't support unsetting of environment variables.</span><span>
</span><span id="line-146"></span><span class="annot"><a href="System.Environment.Blank.html#unsetEnv"><span class="hs-identifier hs-type">unsetEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span id="unsetEnv"><span class="annot"><span class="annottext">unsetEnv :: String -&gt; IO ()
</span><a href="System.Environment.Blank.html#unsetEnv"><span class="hs-pragma hs-var hs-var">{-# LINE 148 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span></a></span></span><span>
</span><span id="line-148"></span><span class="hs-identifier">unsetEnv</span><span> </span><span class="hs-identifier">key</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withCWString</span><span> </span><span class="hs-identifier">key</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">k</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-identifier">success</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_SetEnvironmentVariable</span><span> </span><span class="hs-identifier">k</span><span> </span><span class="hs-identifier">nullPtr</span><span>
</span><span id="line-150"></span><span>  </span><span class="hs-identifier">unless</span><span> </span><span class="hs-identifier">success</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-151"></span><span>    </span><span class="hs-comment">-- We consider unsetting an environment variable that does not exist not as</span><span>
</span><span id="line-152"></span><span>    </span><span class="hs-comment">-- an error, hence we ignore eRROR_ENVVAR_NOT_FOUND.</span><span>
</span><span id="line-153"></span><span>    </span><span class="hs-identifier">err</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_GetLastError</span><span>
</span><span id="line-154"></span><span>    </span><span class="hs-identifier">unless</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">err</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">eRROR_ENVVAR_NOT_FOUND</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-155"></span><span>      </span><span class="hs-identifier">throwGetLastError</span><span> </span><span class="hs-string">&quot;unsetEnv&quot;</span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span class="annot"><a href="System.Environment.Blank.html#eRROR_ENVVAR_NOT_FOUND"><span class="hs-identifier hs-type">eRROR_ENVVAR_NOT_FOUND</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>
</span><span id="line-158"></span><span id="eRROR_ENVVAR_NOT_FOUND"><span class="annot"><span class="annottext">eRROR_ENVVAR_NOT_FOUND :: DWORD
</span><a href="System.Environment.Blank.html#eRROR_ENVVAR_NOT_FOUND"><span class="hs-identifier hs-var hs-var">eRROR_ENVVAR_NOT_FOUND</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">203</span></span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetLastError&quot;</span><span>
</span><span id="line-161"></span><span>  </span><span id="c_GetLastError"><span class="annot"><a href="System.Environment.Blank.html#c_GetLastError"><span class="hs-identifier hs-var">c_GetLastError</span></a></span></span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>
</span><span id="line-162"></span><span>
</span><span id="line-163"></span><span class="hs-pragma">{-# LINE 194 &quot;libraries\\base\\System\\Environment\\Blank.hsc&quot; #-}</span><span>
</span><span id="line-194"></span></pre></body></html>